package com.zhengze;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

// 搜索字符串
public class Demo10 {
    public static void main(String[] args) {
        String str = "the quick brown fox jumps over the lazy dog.";
        String re = "\\wo\\w";
        Pattern pattern = Pattern.compile(re);
        Matcher matcher = pattern.matcher(str);
        // 反复调用find方法，搜索符合正则规则的字符串
        while (matcher.find()) {
            String substring = str.substring(matcher.start(), matcher.end());
            System.out.println(substring);
        }
    }
}

/*
    row
    fox
    dog
 */